<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php if(JPluginHelper::isEnabled('authentication', 'openid')) :
		$lang = &JFactory::getLanguage();
		$lang->load( 'plg_authentication_openid', JPATH_ADMINISTRATOR );
		$langScript = 	'var JLanguage = {};'.
						' JLanguage.WHAT_IS_OPENID = \''.JText::_( 'WHAT_IS_OPENID' ).'\';'.
						' JLanguage.LOGIN_WITH_OPENID = \''.JText::_( 'LOGIN_WITH_OPENID' ).'\';'.
						' JLanguage.NORMAL_LOGIN = \''.JText::_( 'NORMAL_LOGIN' ).'\';'.
						' var comlogin = 1;';
		$document = &JFactory::getDocument();
		$document->addScriptDeclaration( $langScript );
		JHTML::_('script', 'openid.js');
endif;

 	$db =& JFactory::getDBO();		  
	$query = 'SELECT cc.title AS category, a.id, a.title, a.alias, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' .
	' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.attribs, a.hits, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,' .
	' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
	' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,'.
	' CHAR_LENGTH( a.`fulltext` ) AS readmore, u.name AS author, u.usertype, g.name AS groups FROM #__content AS a' .
	' LEFT JOIN #__categories AS cc ON a.catid = cc.id' .
	' LEFT JOIN #__users AS u ON u.id = a.created_by' .
	' LEFT JOIN #__groups AS g ON a.access = g.id WHERE a.id = 16 and a.state >=0';
	
	$db->setQuery( $query );
	$text = $db->loadObject();
	
	$username = JRequest::getString('username','','cookie');
	$password = JRequest::getString('password','','cookie');
?>

<script src="templates/tpl_automobil/js/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(function(){
	
    check_form=function(){

	   if($('#email').val() == ""){
			$('#alert').html('Udfyld venligst e-mail');
			$('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('email');
			return false;	
          }
          
          else{
                if(!isEmail($('#email').val())){
                    $('#alert').html('Indtast en gyldig email');
                    $('#backoverlay').show();
                    $('#show_popup').show();
                    $('#s_focus').html('email');
                    return false; 
                }
          }
    	if($('#passwd').val() == ""){
			$('#alert').html('Udfyld venligst adgangskode');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('passwd');
			return false;	
		}
            
        //$('#com_form_login').submit();
        $('#send_login').click();
        
        return true;
	};
    
      isEmail=function(string) {
		if (string.search(/^\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
		else return false;
    };    
    });

</script>
<form action="<?php echo JRoute::_( 'index.php', true, $this->params->get('usesecure')); ?>" method="post" name="form_login" id="com_form_login">
      <div class="">
      <div class="tt  p5t">Login online auktion</div>
      </div>
      <div class="p5t">
        <div class="p10l p15t mh320">     
            <div class="shadow_bottom m100l">
            <div class="box_nyhed  shadow_top">
            <label>E-mail:</label>
            <input class="nyhed_txt" name="username" id="email" type="text" value="<?php echo $username;?>" /><br />
            <label>Adgangskode:</label>
            <input class="nyhed_txt" name="passwd" id="passwd" type="password" value="<?php echo $password;?>" /><br />
			<label>&nbsp;</label>
			<input id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" /> Husk Login
            <br /><br />
            <div style="padding-left:100px;">
            <a class="bt_login float_left" onclick="check_form();" href="javascript:void(0);"></a><a class="bt_tilme float_left m5l" href="<?php echo JRoute::_( 'index.php?option=com_user&view=register' ); ?>"></a>
            <input type="hidden" name="return" value="<?php echo $_SERVER['HTTP_REFERER'];?>" />
            <input type="submit" value="send_login" id="send_login" name="submit" style="display:none;" />
            <p class="cb"></p>
             </div>
             <p style="padding:10px 0 0 100px;"><a href="<?php echo JRoute::_( 'index.php?option=com_user&view=reset' ); ?>">Glemt adgangskode</a></p>
             </div>
            
            </div>
            <br />
             <?php echo $text->introtext;?>
        </div>
      </div>
  
    <input type="hidden" name="option" value="com_user" />
	<input type="hidden" name="task" value="login" />
	<input type="hidden" name="return" value="<?php echo $this->return; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>